﻿using AutoMapper;
using J.Model;
using J.ProductSet.Application.Command.ClassifiedManagementCommand;
using MediatR;
using SqlSugar;

namespace J.ProductSet.Application.CommandHandler.ClassifiedManagementCommandHandler
{
    public class ClassifiedManagementDeletionCommandHandler : IRequestHandler<ClassifiedManagementDeletionCommand, int>
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        public IMapper _mapper;
        public ClassifiedManagementDeletionCommandHandler(ISqlSugarClient sqlSugarClient, IMapper mapper)
        {
            _sqlSugarClient = sqlSugarClient;
            _mapper = mapper;
        }
        public async Task<int> Handle(ClassifiedManagementDeletionCommand request, CancellationToken cancellationToken)
        {
            return await _sqlSugarClient.Deleteable<ClassifiedManagement>(new ClassifiedManagement() { CategoryManagementID = request.CategoryManagementID }).ExecuteCommandAsync();
        }
    }
}
